const mongoose = require('mongoose')

const Schema  = mongoose.Schema
// 动态评论表
const SpaceCommentType = {
    userId: { type: Schema.Types.ObjectId, ref: 'user' },  // 用户id
    spaceId: { type: Schema.Types.ObjectId, ref: 'space' }, // 说说id
    type: Number, // 评论类型(0 => 自己评论, 1 => 回复评论)
    textarea: String, // 评论内容
    fromId: { type: Schema.Types.ObjectId, ref: 'user' }, // 发送者id
    toId: { type: Schema.Types.ObjectId, ref: 'user' }, // 回复者id(如果 type 为0, fromId 和 toId 都是用户自己)
    time: String // 评论的时间
}

const SpaceCommentModel = mongoose.model('space_comment', new Schema(SpaceCommentType))

module.exports = SpaceCommentModel